package com.wondream.myframework.heima_concurrent;

import java.util.concurrent.*;

/**
 * 第四种创建线程的方式: 使用线程池-Executors
 */
public class _005_Thread_Executors {
    public static void main(String[] args) throws Exception {
        ExecutorService executorService = Executors.newCachedThreadPool();
//        ExecutorService executorService = Executors.newFixedThreadPool(5);
//        ExecutorService executorService = Executors.newSingleThreadExecutor();

        for (int i = 0; i < 5; i++) {
            executorService.execute(new TestThread());
        }

        System.out.println("第四种创建线程的方式: 使用线程池-Executors");;
    }
}

class TestThread implements Runnable {

    @Override
    public void run() {
        System.out.println("执行了run方法");
    }
}
